home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Converse between tasks *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen. All *)
- (* rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- UNIT BBCONV;
-
- INTERFACE
-
- PROCEDURE operator_terminal_task;
- PROCEDURE operator_talk_action;
- PROCEDURE converse_talk_loop;
-
- IMPLEMENTATION
-
- USES
- bbconvm,
- bbdummy,
- bbmess,
- bbmisc4,
- bbocmd,
- bbrdata,
- bbsdata,
- bbsess,
- bbstr,
- bbtask,
- bbtime,
- bbucmd,
- bbuf,
- bbwin;
-
- PROCEDURE operator_talk_loop; FORWARD;
-
- (*===========================================================================*)
- (* Operator talk action -- Called by ocmd to accomplish talk for operator *)
- (* The main part of the operator "T" command is in an overlay. This is the *)
- (* section that cannot be overlayed. *)
- (*===========================================================================*)
-
- PROCEDURE operator_talk_action;
-
- BEGIN;
-
- operator_talk_loop;
-
- IF active_tcb^.conv_tcb = NIL THEN EXIT;
-
- WITH active_tcb^.conv_tcb^ DO
- BEGIN;
-
- IF tcb_type = th_opr_terminal THEN
- BEGIN;
- window := window_connect;
- tcb_ignore_lc := FALSE;
- END;
-
- END;
-
- drop_conv(active_tcb);
-
- END;
-
- (*===========================================================================*)
- (* Operator talk loop -- This is where operator sits while talking *)
- (*===========================================================================*)
-
- PROCEDURE operator_talk_loop;
-
- VAR
- line_from_op : STRING;
-
- BEGIN;
-
- op_busy := TRUE;
-
- (*-----------------------------------------------------------------------*)
- (* This is the talk loop *)
- (*-----------------------------------------------------------------------*)
-
- WHILE TRUE DO
- WITH active_tcb^ DO
- BEGIN;
-
- (*-----------------------------------------------------------------*)
- (* If other TCB gone away, then bye bye *)
- (*-----------------------------------------------------------------*)
-
- IF (conv_tcb = NIL) OR task_is_dead(conv_tcb) THEN EXIT;
-
- (*-----------------------------------------------------------------*)
- (* Get line from operator *)
- (*-----------------------------------------------------------------*)
-
- line_from_op := read_tnc_data_str;
-
- (*-----------------------------------------------------------------*)
- (* If other TCB gone away, then bye bye *)
- (*-----------------------------------------------------------------*)
-
- IF (conv_tcb = NIL) OR task_is_dead(conv_tcb) THEN EXIT;
-
- IF NOT op_busy THEN
- BEGIN;
- op_busy := FALSE;
- IF conv_tcb <> NIL THEN
- conv_tcb^.tcb_opr_talk := FALSE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------*)
- (* Queue the line *)
- (*-----------------------------------------------------------------*)
-
- IF line_from_op = '' THEN
- line_from_op := ' ';
-
- (*-----------------------------------------------------------------*)
- (* Either queue or execute the line *)
- (*-----------------------------------------------------------------*)
-
- IF (line_from_op[0] > #2)
- AND (line_from_op[1] = escape)
- AND (line_from_op[2] = escape) THEN
- BEGIN;
- line_from_op := substr(line_from_op, 3, 0);
- execute_opr_command(@line_from_op);
- error_sw := FALSE;
- END
- ELSE
- add_c_string(conv_tcb, @line_from_op, 0);
-
- (*-----------------------------------------------------------------*)
- (* Delete any lines on the receive side. Note that we don't do *)
- (* anything with them. They have already been written to the *)
- (* screen by the receiving task *)
- (*-----------------------------------------------------------------*)
-
- WHILE c_input <> NIL DO
- BEGIN;
- task_switch;
- del_c_string(active_tcb);
- END;
-
- (*-----------------------------------------------------------------*)
- (* Switch tasks around please *)
- (*-----------------------------------------------------------------*)
-
- task_switch;
-
- END; (*----- Operator talk loop -------------------------------------*)
-
- END;
-
- (*===========================================================================*)
- (* Operator talk sub-task -- Operator using his keyboard as a terminal *)
- (* and we have to create a sub task for the port *)
- (*===========================================================================*)
-
- PROCEDURE operator_terminal_task;
-
- VAR
- i : BYTE;
-
- BEGIN;
-
- FILLCHAR(active_tcb^.tnc_data, SIZEOF(active_tcb^.tnc_data), 0);
-
- FOR i := 1 TO 10 DO
- task_switch;
-
- converse_talk_loop;
-
- active_tcb^.tcb_ignore_lc := FALSE;
-
- end_session(FALSE);
-
- END;
-
- (*===========================================================================*)
- (* Converse talk loop -- This is where the user sits when talking *)
- (*===========================================================================*)
-
- PROCEDURE converse_talk_loop;
-
- VAR
- delay_to_add : BYTE;
- end_talk : BOOLEAN;
- i : BYTE;
- line_to : STRING;
- modem_line : BOOLEAN;
- work_scb : str_m_chain;
-
- LABEL
- leave_loop;
-
- BEGIN;
-
- modem_line := (active_port^.port_type = port_modem)
- OR (active_port^.port_type = port_null_modem);
-
- WITH active_tcb^ DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* If no data then flush things *)
- (*-------------------------------------------------------------------*)
-
- IF c_input = NIL THEN
- send_flush;
-
- (*-------------------------------------------------------------------*)
- (* Initialize for talk loop *)
- (*-------------------------------------------------------------------*)
-
- end_talk := FALSE;
-
- (*-------------------------------------------------------------------*)
- (* Talk loop *)
- (*-------------------------------------------------------------------*)
-
- WHILE (NOT end_talk) AND (conv_tcb <> NIL) DO
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* If incoming data then send it. The local operator can send *)
- (* command to the user's channel. *)
- (*---------------------------------------------------------------*)
-
- IF c_input <> NIL THEN
- BEGIN;
-
- work_scb := c_input;
-
- (*-----------------------------------------------------------*)
- (* Check for incoming command rather than data *)
- (*-----------------------------------------------------------*)
-
- IF (work_scb^.str_m_data.str_data[1] = escape)
- AND (work_scb^.str_m_type = 0)
- AND (NOT active_tcb^.tcb_binary) THEN
- BEGIN;
-
- (*-------------------------------------------------------*)
- (* Strip the escape plus other stuff *)
- (*-------------------------------------------------------*)
-
- line_to := COPY(work_scb^.str_m_data.str_data, 2, 255);
- strip_crlf(line_to);
-
- (*-------------------------------------------------------*)
- (* If a second escape is not present then send command to*)
- (* the TNC else execute the command *)
- (*-------------------------------------------------------*)
-
- IF (LENGTH(line_to) = 0) OR (line_to[1] <> escape) THEN
- cmd_tnc(@line_to, TRUE)
- ELSE
- BEGIN;
-
- {$IFDEF DEBUG}
- WRITELN('Command --', LENGTH(line_to), '-', line_to);
- {$ENDIF}
-
- line_to := COPY(line_to, 2, 255);
- execute_opr_command(@line_to);
- error_sw := FALSE;
- END;
- END
- ELSE
- BEGIN;
-
- {$IFDEF DEBUG}
- WRITELN('Data-', LENGTH(work_scb^.str_m_data.str_data),
- '-', work_scb^.str_m_data.str_data);
- {$ENDIF}
-
- send_tnc_data(@work_scb^.str_m_data);
- send_flush;
- END;
-
- del_c_string(active_tcb);
-
- END; (*----- End the handling of outbound data ----------------*)
-
- (*---------------------------------------------------------------*)
- (* See if any inbound data. If so, distribute that *)
- (*---------------------------------------------------------------*)
-
- i := send_pending(FALSE);
-
- IF conv_tcb = NIL THEN
- GOTO leave_loop;
-
- IF active_tcb^.tcb_binary THEN
- BEGIN;
-
- IF active_tcb^.i_data.long_length <> 0 THEN
- BEGIN;
- add_c_long(conv_tcb, @active_tcb^.i_data);
-
- active_tcb^.i_data.long_length := 0;
- active_tcb^.i_data.str_data := '';
-
- delay_to_add := 1;
- END
- ELSE
- delay_to_add := 5;
-
- END
- ELSE
- BEGIN;
-
- IF read_tnc_data_pending THEN
- BEGIN;
- line_to := read_tnc_data_str;
- add_c_string(conv_tcb, @line_to, 1);
- delay_to_add := 1;
- END
- ELSE
- delay_to_add := 5;
-
- END;
-
- (*---------------------------------------------------------------*)
- (* Switch away! *)
- (*---------------------------------------------------------------*)
-
- IF modem_line THEN
- task_switch
- ELSE
- FOR i := 1 TO delay_to_add DO
- task_switch;
-
- END; (*----- End talk loop ----------------------------------------*)
-
- leave_loop:
-
- (*-------------------------------------------------------------------*)
- (* Talk complete. Remove us from list *)
- (*-------------------------------------------------------------------*)
-
- tcb_opr_talk := FALSE;
-
- END;
-
- END;
-
- END.
-